Skip to content

Commit ef9f1fe

Browse files
address feedback
1 parent 5cb576d commit ef9f1fe

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/local_audio_track.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ proto::OwnedTrack createAudioTrackWithSourceHandle(const std::string& name, std:
3737
msg->set_source_handle(source_handle);
3838

3939
const proto::FfiResponse resp = FfiClient::instance().sendRequest(req);
40+
if (!resp.has_create_audio_track()) {
41+
// TODO(sderosa): we dont have an error code/return, is throwing ok?
42+
throw std::runtime_error("create_audio_track response is missing track");
43+
}
4044
return resp.create_audio_track().track();
4145
}
4246

src/platform_audio.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,18 @@ std::shared_ptr<PlatformAudioSource> PlatformAudio::createAudioSource(const Plat
177177
throw PlatformAudioError("FfiResponse missing new_audio_source");
178178
}
179179

180-
const auto& source = resp.new_audio_source().source();
181-
FfiHandle handle(static_cast<uintptr_t>(source.handle().id()));
180+
const auto& new_source = resp.new_audio_source();
181+
if (!new_source.has_source() || !new_source.source().has_handle()) {
182+
throw PlatformAudioError("NewAudioSourceResponse missing source handle");
183+
}
184+
185+
const auto& source = new_source.source();
186+
const std::uint64_t handle_id = source.handle().id();
187+
if (handle_id == 0) {
188+
throw PlatformAudioError("NewAudioSourceResponse returned an invalid (null) source handle");
189+
}
190+
191+
FfiHandle handle(static_cast<uintptr_t>(handle_id));
182192
return std::shared_ptr<PlatformAudioSource>(new PlatformAudioSource(std::move(handle), state_));
183193
}
184194

0 commit comments

Comments
 (0)