@@ -35,7 +35,7 @@ static ZN7android10AudioTrackC1Ev_t ZN7android10AudioTrackC1Ev = nullptr;
35
35
typedef void (*ZN7android7RefBase12weakref_type7decWeakEPKv_t)(void * thisptr, void * id);
36
36
static ZN7android7RefBase12weakref_type7decWeakEPKv_t ZN7android7RefBase12weakref_type7decWeakEPKv = nullptr ;
37
37
typedef int32_t (*ZN7android10AudioTrack3setE19audio_stream_type_tj14audio_format_t20audio_channel_mask_tm20audio_output_flags_tRKNS_2wpINS0_19IAudioTrackCallbackEEEiRKNS_2spINS_7IMemoryEEEb15audio_session_tNS0_13transfer_typeEPK20audio_offload_info_tRKNS_7content22AttributionSourceStateEPK18audio_attributes_tbfi_t)
38
- (void * thisptr, int32_t streamType, uint32_t sampleRate, uint32_t format, uint32_t channelMask, size_t frameCount /* = 0 */ , uint32_t flags /* = 0 */ , fake_wp callback /* = nullptr */ , int32_t notificationFrames /* = 0 */ , fake_sp sharedMemory /* = nullptr */ , bool threadCanCallJava /* = false */ , int32_t audioSessionId /* = 0 */ , transfer_type transferType /* = TRANSFER_DEFAULT */ , void * offloadInfo /* = nullptr */ , void * attributionSource, void * attributes /* = nullptr */ , bool doNotReconnect /* = false */ , float maxRequiredSpeed /* = 1.0f */ , int selectedDeviceId /* = 0 */ );
38
+ (void * thisptr, int32_t streamType, uint32_t sampleRate, uint32_t format, uint32_t channelMask, size_t frameCount /* = 0 */ , uint32_t flags /* = 0 */ , fake_wp& callback /* = nullptr */ , int32_t notificationFrames /* = 0 */ , fake_sp& sharedMemory /* = nullptr */ , bool threadCanCallJava /* = false */ , int32_t audioSessionId /* = 0 */ , transfer_type transferType /* = TRANSFER_DEFAULT */ , void * offloadInfo /* = nullptr */ , int & attributionSource, void * attributes /* = nullptr */ , bool doNotReconnect /* = false */ , float maxRequiredSpeed /* = 1.0f */ , int selectedDeviceId /* = 0 */ );
39
39
static ZN7android10AudioTrack3setE19audio_stream_type_tj14audio_format_t20audio_channel_mask_tm20audio_output_flags_tRKNS_2wpINS0_19IAudioTrackCallbackEEEiRKNS_2spINS_7IMemoryEEEb15audio_session_tNS0_13transfer_typeEPK20audio_offload_info_tRKNS_7content22AttributionSourceStateEPK18audio_attributes_tbfi_t ZN7android10AudioTrack3setE19audio_stream_type_tj14audio_format_t20audio_channel_mask_tm20audio_output_flags_tRKNS_2wpINS0_19IAudioTrackCallbackEEEiRKNS_2spINS_7IMemoryEEEb15audio_session_tNS0_13transfer_typeEPK20audio_offload_info_tRKNS_7content22AttributionSourceStateEPK18audio_attributes_tbfi = nullptr ;
40
40
41
41
class MyCallback : public virtual android::AudioTrack::IAudioTrackCallback {
@@ -99,15 +99,15 @@ extern "C" JNIEXPORT jlong JNICALL
99
99
Java_org_akanework_gramophone_logic_utils_NativeTrack_create (
100
100
JNIEnv *env, jobject, jobject parcel) {
101
101
auto theTrack = ::operator new (AUDIO_TRACK_SIZE);
102
- memset (theTrack, 0xdeadbeef , AUDIO_TRACK_SIZE);
102
+ memset (theTrack, ( unsigned char ) 0xde , AUDIO_TRACK_SIZE);
103
103
auto holder = new track_holder ();
104
- if (parcel != nullptr ) { // implies SDK >= 31
104
+ if (true || parcel != nullptr ) { // implies SDK >= 31
105
105
// I'm too cool to call AttributionSourceState ctor before using it.
106
106
auto myParcel = ZN7android19parcelForJavaObjectEP7_JNIEnvP8_jobject (env, parcel);
107
107
if (myParcel == nullptr ) {
108
108
ALOGE (" myParcel is NULL" );
109
109
::operator delete (theTrack);
110
- return NULL ;
110
+ return 0 ;
111
111
}
112
112
auto ats = ::operator new (ATTRIBUTION_SOURCE_SIZE);
113
113
memset (ats, 0 , ATTRIBUTION_SOURCE_SIZE);
@@ -130,7 +130,9 @@ Java_org_akanework_gramophone_logic_utils_NativeTrack_doSet(
130
130
JNIEnv *, jobject, jlong ptr) {
131
131
auto holder = (track_holder*) ptr;
132
132
auto refs = holder->callback ->createWeak (holder);
133
- ALOGE (" calling set on %p" , holder->track );
133
+ ALOGE (" calling set on %p with ats %p" , holder->track , holder->ats );
134
+ fake_wp callback = { .thePtr = nullptr };
135
+ fake_sp sharedMemory = { .thePtr = nullptr };
134
136
auto ret = ZN7android10AudioTrack3setE19audio_stream_type_tj14audio_format_t20audio_channel_mask_tm20audio_output_flags_tRKNS_2wpINS0_19IAudioTrackCallbackEEEiRKNS_2spINS_7IMemoryEEEb15audio_session_tNS0_13transfer_typeEPK20audio_offload_info_tRKNS_7content22AttributionSourceStateEPK18audio_attributes_tbfi (
135
137
holder->track ,
136
138
/* streamType = */ 3 /* AUDIO_STREAM_MUSIC */ ,
@@ -139,14 +141,14 @@ Java_org_akanework_gramophone_logic_utils_NativeTrack_doSet(
139
141
/* channelMask = */ 1 ,
140
142
/* frameCount = */ 0 /* default */ ,
141
143
/* flags = */ 0 /* AUDIO_OUTPUT_FLAG_NONE */ ,
142
- /* callback = */ { . thePtr = nullptr } , // TODO add back ptr/refs
144
+ /* callback = */ callback , // TODO add back ptr/refs
143
145
/* notificationFrames = */ 0 /* default */ ,
144
- /* sharedBuffer = */ { . thePtr = nullptr } ,
146
+ /* sharedBuffer = */ sharedMemory ,
145
147
/* threadCanCallJava = */ true ,
146
148
/* sessionId = */ 0 /* default */ ,
147
149
/* transferType = */ TRANSFER_SYNC,
148
150
/* offloadInfo = */ nullptr ,
149
- /* attributionSource = */ holder->ats ,
151
+ /* attributionSource = */ *(( int *) holder->ats ) ,
150
152
/* pAttributes = */ nullptr ,
151
153
/* doNotReconnect = */ true , // for emulating DIRECT track developer UX
152
154
/* maxRequiredSpeed = */ 1 .0f ,
@@ -160,6 +162,12 @@ Java_org_akanework_gramophone_logic_utils_NativeTrack_doSet(
160
162
return ret;
161
163
}
162
164
165
+ extern " C" JNIEXPORT jlong JNICALL
166
+ Java_org_akanework_gramophone_logic_utils_NativeTrack_getRealPtr (
167
+ JNIEnv *, jobject, jlong ptr) {
168
+ return (intptr_t )((track_holder*)ptr)->track ;
169
+ }
170
+
163
171
extern " C" JNIEXPORT void JNICALL
164
172
Java_org_akanework_gramophone_logic_utils_NativeTrack_dtor (
165
173
JNIEnv *, jobject, jlong ptr) {
0 commit comments